Making New Formations
This section is completely optional. It also might be a bit difficult to understand.
The formations available in a mission are fully customizable by the editor. The HS scripts support a maximum of four different formations, although only 2 are included by default. By editing the file "formations.sqs", you can create or modify the formations available in your mission. I suggest you open up that file as you follow along the rest of this section. Formations.sqs is broken into 4 identical sections--one for each of the 4 possible formations.
The first part of each formation contains a few properties. The first variable tells the scripts whether this formation will be used or not. If this is set to 'false', then the formation will not appear or be usable to the player during play, and the rest of the data in that formation will not matter. The next variable holds the string that will be displayed as this formation's name in the command menu. The array after that holds the names of the sound and animation that will be played when the player chooses that formation. Open up the description.ext to see the available sound names. Animation names are available in the animation addon's readme. The last variable holds the RTO's position relative to the player (more below). The next three sections hold the positions of the group members of all three fireteams.
Formations work in this way: each unit's place in formation is determined by a direction relative to the leader (for example, 90 degrees would be to the leader's direct right), as well as a distance away from the leader. When a fireteam is in formation around the player, the fireteam leader considers the player his leader, and he also gets a distance/direction. The rest of the fireteam members stay in their formation relative to their team leader. When the player orders the squad to spread out or close up, then the distance each team member/leader stays from his leader is increased/decreased. Visually, you can imagine units sliding along a line that radiates out from their formation leader, depending on dispersion level. This system allows for formations that can be expanded or contracted to any size, and still look like the same formation. With that in mind, you can draw out your formations and code them in much easier.
Getting back to formations.sqs, each fireteam leader and member has an array that determines their place in formation about the fireteam leader (or the player, for team leaders). They all are in this format:
[direction, dispersion multiplier, additional dispersion]
Direction = the compass direction, relative to the leader, where the unit's spot in formation radiates from.
Dispersion multiplier = a number that is multiplied by (the player's selected dispersion level * the editor-determined formation spacing) in order to find how far away from the leader (or player, for team leaders) the team member stays. You should use the number 1 for your base, meaning that a unit that is supposed to be next to the leader should have a multiplier of about 1, while a unit 2 formation spaces away from the leader should have a 2. Units at angles should have slightly higher or lower multipliers.
Additional dispersion = a number that is multiplied by (the editor determined formation spacing) and added to the number found by the dispersion multiplier, in order to determine the final distance away from the leader. Essentially, this is a constant distance that is added, which is NOT adjusted when the player changes the dispersion level. You should generally keep this number at 0 unless absolutely needed, because otherwise this tends to distort the formation at high or low dispersion levels. If you absolutely cannot get a unit to be where you want him relative to other units, then you might have to adjust this above 0.
When making formations, be sure to test them! And I mean test, test, TEST them! Be sure to see how your formation looks at all dispersion levels. Also use the "birds eye view" by grouping a unit to the player. Also, keep in mind that if the player is only going to have, say, 12 units in his squad in this mission, then you only have to write out the formation positions for those 12 units. The rest can be the default value.
If you do end up making a new formation, please tell me about it! I know from personal experience how much time and effort they take, so I'd like to include any that you make in future updates.